package com.example.administrator.x3picturetransliteration.Home.Presenter.Activity;

import android.content.Context;

import com.example.administrator.x3picturetransliteration.Base.BasePresenter;
import com.example.administrator.x3picturetransliteration.Base.HttpGo;
import com.example.administrator.x3picturetransliteration.Bean.HttpDataBean;

import java.util.HashMap;
import java.util.Map;

import rx.subscriptions.CompositeSubscription;

/**
 * 广告业
 * Created by Administrator on 2019/9/3.
 */

public class AdvertisementPresenter extends BasePresenter{

    public AdvertisementPresenter(Context context, CompositeSubscription mCompositeSubscription) {
        super(context, mCompositeSubscription);
    }

    /** 获取广告信息 */
    public void ad(final Callback mCallback){

        Map<String,String> map = new HashMap<>();

        mCompositeSubscription.add(

                mHttpGo.postSubscription("app_content/ad", map, null,new HttpGo.HttpGoCallback() {
                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(HttpDataBean httpDataBean) {

                        if (httpDataBean.getCode()==0){

                            if (httpDataBean.getData()!=null)mCallback.getData(httpDataBean.getData());

                        }else if (httpDataBean.getCode()==1003){

                            mCallback.getData(null);
                        }
                    }
                })
        );

    }

    /** 点击广告图统计 */
    public void Statistics(String type){

        Map<String,String> map = new HashMap<>();
        map.put("type",type);

        mCompositeSubscription.add(

                mHttpGo.postSubscription("data_statistic/add", map, new HttpGo.HttpGoCallback() {
                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(HttpDataBean httpDataBean) {

                    }
                })
        );

    }

}
